<?php

/**
 * 厅主管理游戏开关
 * User: 胡诚
 * Date: 2018/11/9
 * Time: 12:02
 */

namespace App\Controllers;

use App\Services\GameSwitchService;
use Illuminate\Http\Request;

class GameSwitchController extends BaseController
{
    /**
     * 获取厅主游戏开关数据
     * @param Request $request
     * @return mixed
     * @throws \Illuminate\Validation\ValidationException
     */
    public function getHallConfig(Request $request)
    {
        $this->validate($request, [
            'hall_id' => 'required',
        ]);
        $hallID = $request->input('hall_id');
        return GameSwitchService::getConfig($hallID);
    }


    /**
     * 游戏授权列表
     * @return array
     */
    public function getGamelist()
    {
        return GameSwitchService::getGamelist();
    }

    /**
     *  修改厅主游戏开关数据
     * @param Request $request
     * @return mixed
     * @throws \App\Exceptions\CustomException
     * @throws \Illuminate\Validation\ValidationException
     */
    public function updateHallConfig(Request $request)
    {
        $this->validate($request, [
            'game'    => 'required',
            'hall_id' => 'required|integer'
        ], [
            'hall_id.integer' => ':attribute必须是整数',
        ]);
        $hallId = $request->input('hall_id');
        $valus  = $request->input('game');
        return GameSwitchService::updateConfig($hallId, $valus);
    }
}
